package libtool65.cmd;

import java.io.FileInputStream;
import java.io.IOException;

import libtool65.o65.Module;
import libtool65.o65.Reader;

public class InfoCommand extends Command {

	@Override
	public void execute() throws Exception {
		Reader reader = new Reader();
		for (String file : parameters)
		{
			Module module = null;
			FileInputStream infile = new FileInputStream(file);
			try {
				module = reader.read(infile);
			} catch (Exception e) {
				System.err.println("Error reading file "+file);
			}
			finally
			{
				if (infile != null)
					try { infile.close(); } catch (IOException e) {}
			}
			System.out.println(file+":");
			module.dumpInfo(System.out);
		}
	}

	@Override
	public void printHelp() {
		System.out.println("Prints information in o65 modules.");
	}
}
